package net.paruo.google.gwt.study_meeting.user_control.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;

public class Menu extends Composite {

	private static MenuUiBinder uiBinder = GWT.create(MenuUiBinder.class);

	interface MenuUiBinder extends UiBinder<Widget, Menu> {
	}

	@UiField
	Button btnCreate;
	@UiField
	Button btnSearch;

	public Menu() {
		initWidget(uiBinder.createAndBindUi(this));

	}

	@UiHandler("btnCreate")
	void onClickCreate(ClickEvent e) {
		clear();
		add(new UserCreate());
	}

	@UiHandler("btnSearch")
	void onClickSearch(ClickEvent e) {
		clear();
		add(new UserSearch());
	}

	private void clear() {
		RootPanel.get("main").clear();
	}

	private void add(Widget widget) {
		RootPanel.get("main").add(widget);
	}

}
